package org.NooLab.texx;


import java.io.ByteArrayInputStream;
import java.util.ArrayList;

import org.NooLab.utilities.logging.PrintLog;


import org.NooLab.texx.components.*;




/**
 * 
 * This class organizes the uptake of data from the environment;  </br>
 * possible sources are: </br>
 * - external physical files (txt, xls) </br>
 * - databases  </br>
 * - the (internal) GlueClient </br> </br>
 * 
 * 
 * 
 * 
 */
public class DataReceptor implements // 
										DataFileReceptorIntf,
										DataDBReceptorIntf,
										DataglueReceptorIntf {

	 
	WorkDataObject workData;
	
	String loadedFile = "";
	String preparedFile = "";
	
	String loadedProfileFile;
	
	RawFileData rawFileData, rawFileProfileData;
	
	PrintLog out;

	private Object rawdata;
	// e.g. ByteArrayInputStream, char[], Charbuffer
	
	


	// ------------------------------------------------------------------------
	public DataReceptor(   WorkDataObject workdata) {
		
		workData = workdata;
		
		out = workData.getOut();
	}

	// ------------------------------------------------------------------------

	
	@Override
	public void loadProfilesFromFile(String filename) throws Exception {
		
	}

	@Override
	public void loadFromFile(String filename) throws Exception {
		
		int r;
		out = workData.getOut();

		
		rawFileData = new RawFileData(  workData, out ) ;
		
		r = rawFileData.readRawDatafromFile( filename );
		
		if (r<=0){
			throw(new Exception("file read error for file <"+filename+">"));
		}
		

		
		// rawdata = rawFileData.get();
		
		loadedFile = filename;
		
		// workData.importDataTable( workData.getTransformer(), dataTable );
	
		rawFileData.close();
		
		rawFileData=null;
	}

	@Override
	public String getLoadedFileName() {
		
		return loadedFile;
	}

	/**
	 * @return the rawFileData
	 */
	public RawFileData getRawFileData() {
		return rawFileData;
	}

	
	
}

















